//
//  QuadTree.m
//  Assignment1Q3Q4
//
//  Created by LxL on 2012-10-17.
//
//

#import "QuadTree.h"

@implementation QuadTree

@synthesize root=_root;

-(id) init
{
    if(self=[super init])
    {
        winSize=[[CCDirector sharedDirector] winSize];
        self.root=[[QuadNode alloc] init];
        [self.root CreateNodefrom:nil withBoundingBox:CGRectMake(0, 0, winSize.width, winSize.height)];
        
    }
    return self;
}

//This method is used to update content in QuadNodes og the tree
-(void) UpdateContent:(NSObject*) content
{
    QuadNode* contentNode=((SquareSprite*)content).contentNode;
    [contentNode DeleteContent:content];
    [contentNode UpdateContent:content];
}

//Get list of an SquadSprite object's possible collisions
-(void) GetCollisionCandidatesOf:(NSObject*)content
                         inArray:(NSMutableArray **)candidates
{
//    QuadNode *tmp = [((SquareSprite*)content) contentNode];
    [[((SquareSprite*)content) contentNode] GetContentByTraverseDownAndPutResultIn:candidates];
}

@end
